package com.hui.wanxin.web.config;


import com.hui.wanxin.web.inteceptor.CorsInterceptor;
import com.hui.wanxin.web.inteceptor.LoginInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author: 灰灰
 * @date: 2023年10月11日 20:12
 * @ClassName: InterceptorConfig
 * @Description: TODO
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    //开启跨域
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getCorsInterceptor()).addPathPatterns("/**");
        registry.addInterceptor(getloginInterptor())
                .addPathPatterns("/web/*/**/***")
                .excludePathPatterns("/web/user/login","/web/common/**");
    }

    @Bean
    CorsInterceptor getCorsInterceptor() {
        return new CorsInterceptor();
    }

    @Bean
    LoginInterceptor getloginInterptor() {
        return new LoginInterceptor();
    }
}
